package com.hxzy.controller.cellinfo;

import com.alibaba.fastjson.JSONObject;
import com.hxzy.common.BaseServlet;
import com.hxzy.common.ResultAjax;
import com.hxzy.entity.Cellinfo;
import com.hxzy.service.cellinfoService;
import com.hxzy.service.impl.cellinfoSerxiceIpml;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description:
 * @Author: YangYong
 * @Date: 2022/3/8 15:57
 */
@WebServlet(urlPatterns = "/cellinfo/delete")
public class cellinfo_delete extends BaseServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        try{

        Cellinfo cellinfo =super.CollectiongParameterToJSON(req, Cellinfo.class);
            //修改明文密码为加密的密码(长度验证)

            cellinfoService cellinfoService=new cellinfoSerxiceIpml();
            //调有和新增操


            int count = cellinfoService.delete(cellinfo.getId());

            ResultAjax resultAjax = null;
            if(count>0){
                System.out.println("成功===================================");
                resultAjax =ResultAjax.success();
                super.render(resp, JSONObject.toJSONString(resultAjax));
            }else {
                System.out.println("===================================");
                resultAjax=ResultAjax.error("错误");
            }
            super.render(resp, JSONObject.toJSONString(resultAjax));

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
